﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using SuppKids.Core.Reporting;
using SuppKids.Core.Reporting.Excel;

namespace SuppKids.IoC.Installers
{
	public class ReportGeneratorsInstaller : IWindsorInstaller
	{
		public void Install(IWindsorContainer container, IConfigurationStore store)
		{
			container.Register(this.FindReportGenerators().Configure(x => x.LifestyleTransient().Configuration()));
		}

		private BasedOnDescriptor FindReportGenerators()
		{
			var res = Types.FromAssemblyContaining(typeof(IReportGenerator))
				.BasedOn(typeof(ExcelReportGenerator))
				.If(a => !a.IsAbstract)
				.WithServiceFirstInterface();

			return res;
		}
	}
}